b = []
for j in range(100,1000):
    k = 0
    for i in range(2,j//2+1):
        if j % i == 0:
            k+=1 
    if k == 0:
        b.append(j)
print(b)
c = ["zero", "one", "two", "three", "four", "five", "six","seven", "eight", "nine"]
print(c.index("zero"))
vse = input()
if len(vse.split()) == 3:
    s,d,e = vse.split()
    if s in c and d in c and e in c:
        if s == "zero":
            print("трехзначное не начинается с нуля!")
        else:
            chislo = c.index(s)*100 + c.index(d)*10+c.index(e)
            mm = 0 
            mb = 10000
            for i in b:
                if i <= chislo:
                    mm = i
                if i >= chislo and mb == 10000:
                    mb = i
            print(mb,chislo,mm)
            if chislo - mm > mb-chislo:
 
                print(mb)
            else:
                print(mm)
    else:
        print("Wrong!")
else:
    print("Wrong!")  